package com.ddkj.netty.client;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.ddkj.netty.comm.HttpSender;
import com.ddkj.netty.comm.SaveRequestUtil;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 客户端Handler
 */
public class MyClientHandler extends SimpleChannelInboundHandler<String> {

	@Override
	protected void channelRead0(ChannelHandlerContext channelHandlerContext, String msg) throws Exception {
		System.out.println("Socket客户端收到消息为:--->" + msg);
	}

	/**
	 * 通道不活跃
	 */
	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("Socket客户端：-------->通道不活跃");
	}

	/**
	 * 功能：客户端发生异常的操作
	 */
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		ctx.close();
		System.out.println("Socket客户端：-------->异常信息：\r\n" + cause.getMessage());
	}
}
